package 矩阵.转置矩阵;

import java.util.Arrays;

/**
 * TODO
 *
 * @className: zzjz
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-01 21:24
 * 此题需要注意引用问题
 * int[] a, b
 * a = b 为引用赋值
 **/
public class zzjz {
    public static void main(String[] args) {
//        int[][] arr = {{1,2,3},{4,5,6}};
        int[][] arr = {{1,2,3},{4,5,6},{7,8,9}};
        transpose(arr);

    }
    public static int[][] transpose(int[][] matrix) {
        int y = 0;
        int x = 0;
        int count = 0;
        int sum = 0;
        int[][] result = new int[matrix[x].length][matrix.length];
        int[] temp = new int[matrix.length];
        while (++count<=matrix[x].length*matrix.length){
            temp[x] = matrix[x][y];
            ++x;
            if(x>=matrix.length){

                ++y;
                x = 0;
                System.out.println(count+"--"+matrix[x].length+"--"+sum);
                System.out.println(count/ matrix[x].length);
                result[sum] = temp.clone();
                ++sum;
                if(y >= matrix[x].length){
                    y = 0;
                }

            }
        }
        for (int[] ints : result) {
            System.out.println(Arrays.toString(ints));
        }
        return result;
    }
}
